package test.top2.com.atguigu.utils;

import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;

import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;

/**
 * ClassName: KeywordUtil
 * Package: test.top2.com.atguigu.utils
 * Description:
 *
 * @Author ChenJun(有志男青年)f
 * @Create 2023/5/11 10:25
 * @Version 1.0
 */
public class KeywordUtil {

    public static List<String> splitKeyword(String keyword) throws IOException {
        //创建集合
        ArrayList<String> list = new ArrayList<>();

        IKSegmenter ikSegmenter = new IKSegmenter(new StringReader(keyword), false);

        Lexeme next = ikSegmenter.next();

        while(next != null){
            String lexemeText = next.getLexemeText();

            list.add(lexemeText);
            next = ikSegmenter.next();
        }

        //返回结果
        return list;
    }

    public static void main(String[] args) throws IOException {

        System.out.println(splitKeyword("尚硅谷大数据项目之Flink实时数仓"));

    }
}
